/**
 * Created by qiushaohua on 15-1-28.
 */
define([
    'app',
    'controllers/common/ImgViewController'
], function (app) {

    var deps = ['$modal'];

    function directive($modal) {
        return {
            restrict: 'CA',
            link: function ($scope, elem) {

                elem.on('click', function (event) {
                    var picId = elem.attr('picId');

                    if (!picId || picId == '') {
                        return;
                    }

                    event.stopPropagation();

                    $modal.open({
                        templateUrl: 'views/common/imgView/ImgView.html',
                        controller: 'ImgViewController',
                        backdrop: true,
                        resolve: {
                            picId: function () {
                                return picId;
                            }
                        },
                        keyboard: true,
                        windowClass: 'imgView-dialog-window fancy-scrollbar'
                    });
                });
            }
        };
    }

    directive.$inject = deps;
    return app.lazy.directive("fcImageViewable", directive);
});